import { defineStore } from 'pinia';
import { getSceneConfigList } from '@/api/scene';

export const useSceneStore = defineStore('scene', {
  state: () => {
    // // 场景预览
    // const preview = false;
    // // 场景编辑错误状态
    // const editError = false;

    // const leftPanelActive = '';
    // const leftPanelVisible = false;
    // const mapPanelVisible = false;

    // const isCimupComplete = false;
    // // 场景详情
    // const sceneDetail = null as any;
    // // 选中的在线地图列表
    // const onlineMapSels = [] as any;

    // // 图层列表
    // const layerList = [] as any;

    // // 场景版本列表
    // const versionList = [] as any;
    // // 当前选中的图层
    // const selLayer = null as any;
    // // 特效弹窗
    // const specialEffectVisible = false;
    // // 底座高程
    // const mapCameraHeight = 100000;
    // // 特效库打点状态
    // const effectDotState = false;

    return {
      // 场景预览
      preview: false,
      // 场景编辑错误状态
      editError: false,

      leftPanelActive: '',
      leftPanelVisible: false,
      mapPanelVisible: false,

      isCimupComplete: false,
      // 场景详情
      sceneDetail: null as any,
      // 选中的在线地图列表
      onlineMapSels: [] as any,

      // 图层列表
      layerList: [] as any,
      // 图层树
      layerTree: [] as any,
      selectedLayerNode: null as any,
      sourceType: '',
      expandedKeys: [],

      // 场景版本列表
      versionList: [] as any,
      // 当前选中的图层
      selLayer: null as any,
      // 特效弹窗
      specialEffectVisible: false,
      // 底座高程
      mapCameraHeight: 100000,
      // 特效库打点状态
      effectDotState: false,
      // 全局特特效弹窗
      globalEffectVisible: true,
      globalEffectSetting: {} as any,
      // 默认为'' 鼠标样式 select: 选择, selectable: 可选择状态, unselectable: 不可选
      mouseClass: '',
      // 特效临时面板属性
      effectTemporaryAttr: null,
      // POI特效临时面板属性特殊状态
      poiEffectTemporaryLayernames: [] as string[],
      // 右侧面板状态，是否收起
      rightPanelVisible: false,
      // 图层显示状态
      layerPanelVisible: false,
      // div图层选中标记
      divEditLayerName: '',
      topHeight: 'calc(100% - 28px)', // 左侧面板高度
      activeTerrains: [] as any,
      activeWhiteMolds: [] as any,
    };
  },
  actions: {
    // 查询版本列表
    async getVersionList() {
      await getSceneConfigList({ params: { activityId: this.sceneDetail!.activityId } }).then(
        (res: API.Scene.IVersion[]) => {
          this.versionList = res;
        }
      );
    },
  },
});
